#!/bin/sh
convert IMG_9114.JPG -lat 32x32 test/IMG_9114-lat.png
convert test/IMG_9114-lat.png -fill white -fuzz 10% +opaque "#000000"  -threshold 39% test/IMG_9114-fuzz.png
convert -negate -level 15%,70% test/IMG_9114-fuzz.png test/IMG_9114-grey.png
convert -morphology Erode Octagon:2 test/IMG_9114-grey.png test/IMG_9114-erode.png
convert test/IMG_9114-grey.png -threshold 50% test/IMG_9114-mask.png
#convert ../temp-results/$$neg-grey.png \( ../temp-results/$$mask.png -negate -evaluate multiply 2 \) \
#        -alpha off -compose copy_opacity -composite -negate ../temp-results/$$final.png
convert IMG_9114.JPG -fx '(g+b)/2' -colorspace Gray test/IMG_9114-grey.png
convert test/IMG_9114-grey.png \( test/IMG_9114-mask.png         -evaluate multiply 2 \) -alpha off -compose copy_opacity -composite test/IMG_9114-final.png
#convert IMG_9114.JPG \( test/IMG_9114-mask.png -negate -evaluate multiply 2 \) -alpha off -compose copy_opacity -composite test/IMG_9114-final.png
# convert -flatten test/IMG_9114-final.png -colorspace Gray test/IMG_9114-done.png
convert  test/IMG_9114-grey.png  test/IMG_9114-mask.png -alpha off -compose CopyOpacity -composite test/IMG_9114-final2.png
